package top.xunfong.probe.service.impl;

import top.xunfong.common.core.constant.SecurityConstants;
import top.xunfong.api.probe.domain.dto.ProbeDTO;
import top.xunfong.api.probe.model.RemoteProbeService;
import top.xunfong.probe.service.ProbeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * 默认探针服务实现类
 */
@Service
@Primary
public class DefaultProbeServiceImpl implements ProbeService {

    @Autowired
    private RemoteProbeService remoteProbeService;

    @Override
    public void send(ProbeDTO dto) {
        // 默认直接保存到数据库
        // 建议直接保存到数据库，数据量小时可以使用
        // localSend();

        // 远程调用探针入库服务，不建议
        remoteSend(dto);
    }

    public void localSend() {

    }

    public void remoteSend(ProbeDTO dto) {
        remoteProbeService.sendSingle(dto, SecurityConstants.INNER);
    }
}
